home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib.fmt / c / dbm.man < prev    next >
Encoding:
Text File  |  1989-10-26  |  4.3 KB  |  133 lines

  1.  
  2.  
  3.  
  4. DBM                   C Library Procedures                    DBM
  5.  
  6.  
  7.  
  8. NNAAMMEE
  9.      dbminit, fetch, store, delete, firstkey, nextkey - data base
  10.      subroutines
  11.  
  12. SSYYNNOOPPSSIISS
  13.      ##iinncclluuddee <<ddbbmm..hh>>
  14.  
  15.      ttyyppeeddeeff ssttrruucctt {{
  16.           cchhaarr **ddppttrr;;
  17.           iinntt ddssiizzee;;
  18.      }} ddaattuumm;;
  19.  
  20.      ddbbmmiinniitt((ffiillee))
  21.      cchhaarr **ffiillee;;
  22.  
  23.      ddaattuumm ffeettcchh((kkeeyy))
  24.      ddaattuumm kkeeyy;;
  25.  
  26.      ssttoorree((kkeeyy,, ccoonntteenntt))
  27.      ddaattuumm kkeeyy,, ccoonntteenntt;;
  28.  
  29.      ddeelleettee((kkeeyy))
  30.      ddaattuumm kkeeyy;;
  31.  
  32.      ddaattuumm ffiirrssttkkeeyy(())
  33.  
  34.      ddaattuumm nneexxttkkeeyy((kkeeyy))
  35.      ddaattuumm kkeeyy;;
  36.  
  37. DDEESSCCRRIIPPTTIIOONN
  38.      NNoottee:: tthhee ddbbmm lliibbrraarryy hhaass bbeeeenn ssuuppeerrcceeddeedd bbyy nnddbbmm((33)),, aanndd iiss
  39.      nnooww iimmpplleemmeenntteedd uussiinngg nnddbbmm..  These functions maintain
  40.      key/content pairs in a data base.  The functions will handle
  41.      very large (a billion blocks) databases and will access a
  42.      keyed item in one or two file system accesses.  The func-
  43.      tions are obtained with the loader option --llddbbmm.
  44.  
  45.      _K_e_ys and _c_o_n_t_e_n_ts are described by the _d_a_t_u_m typedef.  A
  46.      _d_a_t_u_m specifies a string of _d_s_i_z_e bytes pointed to by _d_p_t_r.
  47.      Arbitrary binary data, as well as normal ASCII strings, are
  48.      allowed.  The data base is stored in two files.  One file is
  49.      a directory containing a bit map and has `.dir' as its suf-
  50.      fix.  The second file contains all data and has `.pag' as
  51.      its suffix.
  52.  
  53.      Before a database can be accessed, it must be opened by
  54.      _d_b_m_i_n_i_t. At the time of this call, the files _f_i_l_e..ddiirr and
  55.      _f_i_l_e..ppaagg must exist.  (An empty database is created by
  56.      creating zero-length `.dir' and `.pag' files.)
  57.  
  58.      Once open, the data stored under a key is accessed by _f_e_t_c_h
  59.      and data is placed under a key by _s_t_o_r_e.  A key (and its
  60.  
  61.  
  62.  
  63. Sprite v1.0               May 12, 1986                          1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. DBM                   C Library Procedures                    DBM
  71.  
  72.  
  73.  
  74.      associated contents) is deleted by _d_e_l_e_t_e.  A linear pass
  75.      through all keys in a database may be made, in an
  76.      (apparently) random order, by use of _f_i_r_s_t_k_e_y and _n_e_x_t_k_e_y.
  77.      _F_i_r_s_t_k_e_y will return the first key in the database.  With
  78.      any key _n_e_x_t_k_e_y will return the next key in the database.
  79.      This code will traverse the data base:
  80.  
  81.           ffoorr (key = firstkey(); key.dptr != NULL; key =
  82.           nextkey(key))
  83.  
  84. DDIIAAGGNNOOSSTTIICCSS
  85.      All functions that return an _i_n_t indicate errors with nega-
  86.      tive values.  A zero return indicates ok.  Routines that
  87.      return a _d_a_t_u_m indicate errors with a null (0) _d_p_t_r.
  88.  
  89. SSEEEE AALLSSOO
  90.      ndbm(3)
  91.  
  92. BBUUGGSS
  93.      The `.pag' file will contain holes so that its apparent size
  94.      is about four times its actual content.  Older UNIX systems
  95.      may create real file blocks for these holes when touched.
  96.      These files cannot be copied by normal means (cp, cat, tp,
  97.      tar, ar) without filling in the holes.
  98.  
  99.      _D_p_t_r pointers returned by these subroutines point into
  100.      static storage that is changed by subsequent calls.
  101.  
  102.      The sum of the sizes of a key/content pair must not exceed
  103.      the internal block size (currently 1024 bytes).  Moreover
  104.      all key/content pairs that hash together must fit on a sin-
  105.      gle block.  _S_t_o_r_e will return an error in the event that a
  106.      disk block fills with inseparable data.
  107.  
  108.      _D_e_l_e_t_e does not physically reclaim file space, although it
  109.      does make it available for reuse.
  110.  
  111.      The order of keys presented by _f_i_r_s_t_k_e_y and _n_e_x_t_k_e_y depends
  112.      on a hashing function, not on anything interesting.
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. Sprite v1.0               May 12, 1986                          2
  130.  
  131.  
  132.  
  133.